#ifndef Task_h__
#define Task_h__

struct Ray_Trace_Task
{
    Ray_Trace_Task()
    {
        start[0] =  start[1] = finish[0] = finish[1] = 0;
        colorMask[0] = colorMask[1] = colorMask[2] = 1;
    }
    Ray_Trace_Task(int sx, int fx, int sy, int fy)
    {
        start[0] = sx; start[1] = sy;
        finish[0] = fx; finish[1] = fy;
        colorMask[0] = colorMask[1] = colorMask[2] = 1;
    }
    Ray_Trace_Task(int sx, int fx, int sy, int fy, float r, float g, float b)
    {
        start[0] = sx; start[1] = sy;
        finish[0] = fx; finish[1] = fy;
        colorMask[0] = r;colorMask[1] = g;colorMask[2] = b;
    }
    int start[2];
    int finish[2];
    float colorMask[3];

    void SetMask(float r, float g, float b)
    {
        colorMask[0] = r;colorMask[1] = g;colorMask[2] = b;
    }
};

static void SplitTaskInto4(Ray_Trace_Task& source, Ray_Trace_Task* arrayOf4)
{
    int midX = source.start[0] + ((source.finish[0] - source.start[0]) / 2);
    int midY = source.start[1] + ((source.finish[1] - source.start[1]) / 2);
    //Top Left
    arrayOf4[0].start[0] = source.start[0];
    arrayOf4[0].finish[0] = midX;
    arrayOf4[0].start[1] = source.start[1];
    arrayOf4[0].finish[1] = midY;
    //Top Right
    arrayOf4[1].start[0] = midX;
    arrayOf4[1].finish[0] = source.finish[0];
    arrayOf4[1].start[1] = source.start[1];
    arrayOf4[1].finish[1] = midY;
    //Bottom LEft
    arrayOf4[2].start[0] = source.start[0];
    arrayOf4[2].finish[0] = midX;
    arrayOf4[2].start[1] = midY;
    arrayOf4[2].finish[1] = source.finish[1];
    //Bottom Right
    arrayOf4[3].start[0] = midX;
    arrayOf4[3].finish[0] = source.finish[0];
    arrayOf4[3].start[1] = midY;
    arrayOf4[3].finish[1] = source.finish[1];

    arrayOf4[0].SetMask(1.0f, 0.5f, 0.1f);
    arrayOf4[1].SetMask(0.3f, 1.0f, 1.0f);
    arrayOf4[2].SetMask(0.5f, 1.0f, 0.5f);
    arrayOf4[3].SetMask(1.0f, 0.4f, 0.4f);
};

#endif // Task_h__
